/************************************************************************/
// file		: InputBuffer.cpp											//
// date		: 2013-5-11  17:20											//
// author	: hotlala8088@gmail.com										//                                          
/************************************************************************/
#include "InputBuffer.h"
#include <ace/Message_Block.h>
InputBuffer::InputBuffer(size_t size)
:buffer_(NULL)
{
	buffer_ = new ACE_Message_Block(size);
}

InputBuffer::InputBuffer(ACE_Message_Block * buffer)
:buffer_(buffer){}

InputBuffer::~InputBuffer()
{
	if( NULL != buffer_ )
		delete buffer_;
}

bool 
InputBuffer::Next(void const ** data, int* size)
{
	*data = buffer_->rd_ptr();
	*size = buffer_->length();
	return true;
}

void 
InputBuffer::BackUp(int count)
{
	//UNDO	
}

bool 
InputBuffer::Skip(int count)
{
	if(count > buffer_->length()) 
		return false;
	buffer_->rd_ptr(count);
	return true;
}

::google::protobuf::int64 
InputBuffer::ByteCount() const
{
	return buffer_->length();
}
